<template>
  <div class="content">
    <div class="header_top">
      <div class="header_top_search">
        <div class="search">
          <div class="search_bg">
            <img src="../assets/images/img/search.png" alt class="img_ss" />
          </div>
          <input type="text" class="search_inpt" :class="{'search_inpt_bg':search_inpt_bg_is}" @input="changeInput"
            v-model="search_ss" placeholder="请输入地址/名称/姓名/类别/单位" />
          <img src="../assets/images/mhcx_clear.png" class="img_xx" v-show="search_inpt_bg_is" @click="search_xx" />
        </div>
        <img src="../assets/images/img/xj.png" alt class="img_xj" v-show="!search_inpt_bg_is" @click="scan" />
        <div class="btn_ss" v-show="search_inpt_bg_is" @click="onRefresh">搜索</div>
      </div>
      <div v-show="yinchang" style="width:100%;">
        <div class="box">
          <div v-for="(item, index) in listArry" style="position: relative;" :key="index" @click="showed(index,item.id)"
            v-if="index<4" :class="{'grayscale':item.onclick==false}">
            <div class="redx" v-show="red_is"></div>
            <div class="redx" v-show="index==1&&red_is_rwjb"></div>
            <img class="hours" :src="item.imgurl" />
            <div class="words">{{ item.txt }}</div>
          </div>
        </div>
        <div class="box">
          <div v-for="(item, index) in listArry" style="position: relative;" :key="index" @click="showed(index,item.id)"
            v-if="index>3" :class="{'grayscale':item.onclick==false}">
            <div class="redx" v-show="red_is"></div>
            <div class="redx" v-show="index==1&&red_is_rwjb"></div>
            <img class="hours" :src="item.imgurl" />
            <div class="words">{{ item.txt }}</div>
          </div>
        </div>
      </div>
    </div>
    <div class="main-index" :class="{'mar-top':yinchang==false}">
      <div class="hr"></div>
      <div class="main_item">

        <div class="item_left">
          <div class="item_left_top">
            <div class="item_left_top_item" >
              <img src="../assets/images/logo5.png" alt class="img_list" />
              <span >头部完头部完头部完头部完头部完头部完头</span>
            </div>
            <div class="miaoshu">部完头部完头部完头部完头...</div>
          </div>
          <div class="item_left_bottom">
            <div>1小时</div>
            <!--  {{dateTime(item.fbsj, item.nowDate).time}} -->
            <!-- <img src="../assets/images/news.png" alt="" class="img_news"
                  v-show='dateTime(item.fbsj, item.nowDate).show=="true"'> -->
          </div>
        </div>
        <div class="ffdd">
          <img
            src="http://219.153.71.175:8015/yzssapp/WebFiles/img/2020-08-31/726663c6-acb7-491f-bc81-734deb8c8ffa1598869563085.jpg"
            alt="" class="img_item">
          <div class="zhezhao"></div>
        </div>
      </div>
      <div class="main_item">

        <div class="item_left">
          <div class="item_left_top">
            <div class="item_left_top_item" >
              <img src="../assets/images/logo5.png" alt class="img_list" />
              <span >头部完头部完头部完头</span>
            </div>
            <div class="miaoshu">部完头部完头部完头部完头部完头部完头部完头...</div>
          </div>
          <div class="item_left_bottom">
            <div>1小时</div>
            <!--  {{dateTime(item.fbsj, item.nowDate).time}} -->
            <!-- <img src="../assets/images/news.png" alt="" class="img_news"
                  v-show='dateTime(item.fbsj, item.nowDate).show=="true"'> -->
          </div>
        </div>
        <div class="ffdd">
          <img
            src="http://219.153.71.175:8015/yzssapp/WebFiles/img/2020-08-31/726663c6-acb7-491f-bc81-734deb8c8ffa1598869563085.jpg"
            alt="" class="img_item">
          <div class="zhezhao"></div>
        </div>
      </div>
      <!-- <van-pull-refresh v-model="refreshing" @refresh="onRefresh"> -->
      <!-- <van-list v-model="loading" :finished="finished" @load="onLoad">
        <div class="main_item" v-for="(item, index) in list" :key="index" @click="btn(item)">
          <div class="item_left" v-if="item.type=='巡查排查'">
            <div class="item_left_top" v-if="item.lev==0 || item.lev==-1">
              <img src="../assets/images/logo5.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.jc}}巡查{{item.unitsName}}{{item.isok==1?"发现隐患":""}}
            </div>
            <div class="item_left_top" v-else-if="item.lev==1 || item.lev==2">
              <img src="../assets/images/logo5.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.dwName}}{{item.zhiwu}}{{item.endName}}巡查{{item.jc}}{{item.unitsName}}{{item.isok==1?"发现隐患":""}}
            </div>
            <div class="item_left_bottom">
              <div class="deletd">
                <div>{{filterFun(item.title)}}</div>
              </div>
              <img :src="img_path+img_qiege(item.imgurl)" alt class="img_item" />
              <div class="zhezhao"></div>
            </div>
          </div>
          <div class="item_left" v-else-if="item.type=='风险研判'">
            <div class="item_left_top" v-if="item.lev==0 || item.lev==-1">
              <img src="../assets/images/yanpan.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.jc}}开展{{item.type}}
            </div>
            <div class="item_left_top" v-else-if="item.lev==1 || item.lev==2">
              <img src="../assets/images/yanpan.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.dwName}}{{item.zhiwu}}{{item.endName}}组织{{item.type}}
            </div>
            <div class="item_left_bottom">
              <div class="deletd">
                <div>{{filterFun(item.title)}}</div>
              </div>
              <img :src="img_path+img_qiege(item.imgurl)" alt class="img_item" />
              <div class="zhezhao"></div>
            </div>
          </div>
          <div class="item_left" v-else-if="item.type=='网络安全宣传'">
            <div class="item_left_top" v-if="item.lev==0 || item.lev==-1">
              <img src="../assets/images/wangluo.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.jc}}开展{{item.type}}
            </div>
            <div class="item_left_top" v-else-if="item.lev==1 || item.lev==2">
              <img src="../assets/images/wangluo.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.dwName}}{{item.zhiwu}}{{item.endName}}组织{{item.type}}
            </div>
            <div class="item_left_bottom">
              <div class="deletd">
                <div>{{filterFun(item.title)}}</div>
              </div>
              <img :src="img_path+img_qiege(item.imgurl)" alt class="img_item" />
              <div class="zhezhao"></div>
            </div>
          </div>
          <div class="item_left" v-else-if="item.type=='入户安全宣传'">
            <div class="item_left_top" v-if="item.lev==0 || item.lev==-1">
              <img src="../assets/images/ruhu.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.jc}}开展{{item.type}}
            </div>
            <div class="item_left_top" v-else-if="item.lev==1 || item.lev==2">
              <img src="../assets/images/ruhu.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.dwName}}{{item.zhiwu}}{{item.endName}}组织{{item.type}}
            </div>
            <div class="item_left_bottom">
              <div class="deletd">
                <div>{{filterFun(item.title)}}</div>
              </div>
              <img :src="img_path+img_qiege(item.imgurl)" alt class="img_item" />
              <div class="zhezhao"></div>
            </div>
          </div>
          <div class="item_left" v-else-if="item.type=='现场安全宣传'">
            <div class="item_left_top" v-if="item.lev==0 || item.lev==-1">
              <img src="../assets/images/xianchang.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.jc}}开展{{item.type}}
            </div>
            <div class="item_left_top" v-else-if="item.lev==1 || item.lev==2">
              <img src="../assets/images/xianchang.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.dwName}}{{item.zhiwu}}{{item.endName}}组织{{item.type}}
            </div>
            <div class="item_left_bottom">
              <div class="deletd">
                <div>{{filterFun(item.title)}}</div>
              </div>
              <img :src="img_path+img_qiege(item.imgurl)" alt class="img_item" />
              <div class="zhezhao"></div>
            </div>
          </div>
          <div class="item_left" v-else-if="item.type=='隐患协调'">
            <div class="item_left_top" v-if="item.lev==0 || item.lev==-1">
              <img src="../assets/images/xietiao.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.jc}}开展{{item.type}}
            </div>
            <div class="item_left_top" v-else-if="item.lev==1 || item.lev==2">
              <img src="../assets/images/xietiao.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.dwName}}{{item.zhiwu}}{{item.endName}}组织{{item.type}}
            </div>
            <div class="item_left_bottom">
              <div class="deletd">
                <div>{{filterFun(item.title)}}</div>
              </div>
              <img :src="img_path+img_qiege(item.imgurl)" alt class="img_item" />
              <div class="zhezhao"></div>
            </div>
          </div>
          <div class="item_left" v-else-if="item.type=='警示约谈'">
            <div class="item_left_top" v-if="item.lev==0 || item.lev==-1">
              <img src="../assets/images/yuetan.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.jc}}开展{{item.type}}
            </div>
            <div class="item_left_top" v-else-if="item.lev==1 || item.lev==2">
              <img src="../assets/images/yuetan.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.dwName}}{{item.zhiwu}}{{item.endName}}组织{{item.type}}
            </div>
            <div class="item_left_bottom">
              <div class="deletd">
                <div>{{filterFun(item.title)}}</div>
              </div>
              <img :src="img_path+img_qiege(item.imgurl)" alt class="img_item" />
              <div class="zhezhao"></div>
            </div>
          </div>
          <div class="item_left" v-else-if="item.type=='实战演练'">
            <div class="item_left_top" v-if="item.lev==0 || item.lev==-1">
              <img src="../assets/images/yanlian.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.jc}}开展{{item.type}}
            </div>
            <div class="item_left_top" v-else-if="item.lev==1 || item.lev==2">
              <img src="../assets/images/yanlian.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.dwName}}{{item.zhiwu}}{{item.endName}}组织{{item.type}}
            </div>
            <div class="item_left_bottom">
              <div class="deletd">
                <div>{{filterFun(item.title)}}</div>
              </div>
              <img :src="img_path+img_qiege(item.imgurl)" alt class="img_item" />
              <div class="zhezhao"></div>
            </div>
          </div>
          <div class="item_left" v-else-if="item.type=='桌面推演'">
            <div class="item_left_top" v-if="item.lev==0 || item.lev==-1">
              <img src="../assets/images/tuiyan.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.jc}}开展{{item.type}}
            </div>
            <div class="item_left_top" v-else-if="item.lev==1 || item.lev==2">
              <img src="../assets/images/tuiyan.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.dwName}}{{item.zhiwu}}{{item.endName}}组织{{item.type}}
            </div>
            <div class="item_left_bottom">
              <div class="deletd">
                <div>{{filterFun(item.title)}}</div>
              </div>
              <img :src="img_path+img_qiege(item.imgurl)" alt class="img_item" />
              <div class="zhezhao"></div>
            </div>
          </div>
          <div class="item_left" v-else-if="item.type=='安全培训'">
            <div class="item_left_top" v-if="item.lev==0 || item.lev==-1">
              <img src="../assets/images/peixun.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.jc}}开展{{item.type}}
            </div>
            <div class="item_left_top" v-else-if="item.lev==1 || item.lev==2">
              <img src="../assets/images/peixun.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.dwName}}{{item.zhiwu}}{{item.endName}}组织{{item.type}}
            </div>
            <div class="item_left_bottom">
              <div class="deletd">
                <div>{{filterFun(item.title)}}</div>
              </div>
              <img :src="img_path+img_qiege(item.imgurl)" alt class="img_item" />
              <div class="zhezhao"></div>
            </div>
          </div>
          <div class="item_left" v-else-if="item.type=='安排部署'">
            <div class="item_left_top" v-if="item.lev==0 || item.lev==-1">
              <img src="../assets/images/bushu.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.jc}}开展{{item.type}}
            </div>
            <div class="item_left_top" v-else-if="item.lev==1 || item.lev==2">
              <img src="../assets/images/bushu.png" alt class="img_list" />
              {{titleTime(item.TIME)}}日{{item.dwName}}{{item.zhiwu}}{{item.endName}}组织{{item.type}}
            </div>
            <div class="item_left_bottom">
              <div class="deletd">
                <div>{{filterFun(item.title)}}</div>
              </div>
              <img :src="img_path+item.imgurl" alt class="img_item" />
              <div class="zhezhao"></div>
            </div>
          </div>
        </div>
      </van-list> -->
      <!-- </van-pull-refresh> -->
    </div>

    <div class="content_box" v-if="fuck">
      <div class="content_box_song">
        <div class="fb">新版发布</div>
        <div class="savegg">应急安全管理平台最新版本发布啦,欢迎体验!</div>
        <div class="line"></div>
        <div class="makesure" @click="UPdatas">立即更新</div>
      </div>
    </div>
    <!-- 底部 -->
    <Tabbar id="yy" v-if="isOriginHei"></Tabbar>
  </div>
</template>

<script>
  import { Dialog } from "vant";
  import Header from "../components/header";
  import Tabbar from "../components/tabbar";
  export default {
    name: "index",
    data() {
      return {
        fuck: false,
        listArry: [
          {
            imgurl: require("../assets/images/img/b1.png"),
            txt: "监督检查计划",
            id: 0,
            onclick: true,
          },
          {
            imgurl: require("../assets/images/img/b2.png"),
            txt: "任务交办",
            id: 1,
          },
          {
            imgurl: require("../assets/images/img/b3.png"),
            txt: "宣传部署",
            id: 2,
            onclick: true,
          },
          {
            imgurl: require("../assets/images/img/b4.png"),
            txt: "巡查排查",
            id: 3,
            onclick: true,
          },
          // {
          //   imgurl: require("../assets/images/img/b7.png"),
          //   txt: "点位巡查",
          //   id: 8,
          //   onclick: true
          // },
          {
            imgurl: require("../assets/images/img/b5.png"),
            txt: "隐患整治",
            id: 4,
            onclick: true,
          },
          {
            imgurl: require("../assets/images/img/b6.png"),
            txt: "辖企档案",
            id: 5,
            onclick: true,
          },
          {
            imgurl: require("../assets/images/img/b7.png"),
            txt: "统计查询",
            id: 6,
            onclick: false,
          },
          {
            imgurl: require("../assets/images/img/b8.png"),
            txt: "数据地图",
            id: 7,
            onclick: true,
          },
        ],
        show: false,
        isshow: false,
        sort: 0, //app版本是否需要更新的状态变量
        phone_type: null, //判断手机是什么系统,0为ios，1为安卓
        data_repa: [],
        red_is: false,
        red_is_rwjb: false,
        userId: null,
        tel: null,
        url: "",
        wgtVersion: "", //版本号
        cardWhether: null, //是否身份证验证
        path: null,
        showeditionObj: null,
        rank: null, //等级 区级、街道、科室、社区
        clickNum: 0,
        search_ss: "", //输入框的值
        search_inpt_bg_is: false,
        yinchang: true, //小模块显示
        scroll: 0,
        cunt: 1,
        list: [], //新闻列
        img_path: "http://219.153.71.175:8015/yzssapp",
        loading: false, //加载状态结束false
        finished: false, //全部加载完成true
        error: false, //出错状态
        refreshing: false, //是否下拉加载 是true
        total: null,
        xcbslist: [
          "风险研判",
          "安排部署",
          "安全培训",
          "桌面推演",
          "实战演练",
          "隐患协调",
          "现场安全宣传",
          "入户安全宣传",
          "网络安全宣传",
          "警示约谈",
        ], //宣传布署对象
        documentHeight: document.documentElement.clientHeight,
        isOriginHei: true, //显示或者隐藏footer
      };
    },
    mounted() {
      var _this = this;
      // if (window.history && window.history.pushState) {
      //   history.pushState(null, null, document.URL);
      //   window.addEventListener("popstate", this.back, false); //false阻止默认事件
      // }
      document.addEventListener("scroll", this.scrollfunc, true);
      window.onresize = () => {
        return (() => {
          if (this.documentHeight > document.documentElement.clientHeight) {
            this.isOriginHei = false;
          } else {
            this.isOriginHei = true;
          }
        })();
      };
    },
    // destroyed() {
    //   window.removeEventListener("popstate", this.back, false); //false阻止默认事件
    // },
    methods: {
      search_xx() {
        this.search_ss = '';
        this.search_inpt_bg_is = false
      },
      img_qiege(i) {
        return i.split(",")[0];
      },
      btn(item) {
        sessionStorage.setItem("showed", 2)
        console.log(item);
        console.log(this.xcbslist.indexOf(item.type));
        localStorage.setItem("index_scroll", this.scroll);
        localStorage.setItem("userId", item.userId);
        if (item.type == "巡查排查") {
          sessionStorage.setItem("inspection_patrolTroubleshootId", item.id);
          if (item.isok == 0) {
            sessionStorage.setItem("inspection_infoId", 0);
          } else {
            sessionStorage.setItem("inspection_infoId", item.ptiid);
          }
          localStorage.setItem("hard_detail_from", "/index");
          this.$router.push("/hard_detail");
        } else if (this.xcbslist.indexOf(item.type) != -1) {
          var kfc = {
            id: item.id,
            lujing: "index",
          };
          sessionStorage.setItem("todetail", JSON.stringify(kfc));
          this.$router.push("/xcbs_detail");
        }
      },
      titleTime(value) {
        return value.replace("-", "月");
      },
      scrollfunc() {
        var scroll_1 = $(".content").scrollTop();
        // console.log(scroll_1)
        if (scroll_1 < 300) {
          this.yinchang = true;
          return false;
          // console.log(124)
        }
        if ($(".main-index").height() - scroll_1 < 705) {
          this.yinchang = false;
          return false
        }
        if (scroll_1) {
          if (this.scroll > scroll_1) {
            this.yinchang = true;
            // $(".tou").addClass("posi")
          } else {
            this.yinchang = false;
          }
          this.scroll = scroll_1;
        }
        // console.log(this.scroll);
      },

      scan() {
        //  扫一扫
        // this.show=false
        sessionStorage.removeItem("qujiname");
        sessionStorage.removeItem("jiedaoname");
        sessionStorage.removeItem("shequname");
        sessionStorage.removeItem("number");
        sessionStorage.removeItem("yeschuan");
        sessionStorage.removeItem("str");
        sessionStorage.removeItem("fidname");
        sessionStorage.removeItem("didname");
        localStorage.removeItem("xcpc_da_obj");
        localStorage.removeItem("xcdx_map_xcdxObj");
        localStorage.setItem("xcpc_scan_fanhui", "/index");
        this.$router.push("/xcpc_scan");
      },
      filterFun(value) {
        if (value && value.length > 49) {
          value = value.substring(0, 49) + "...";
        }
        return value;
      },
      dateTime(start, current) {
        //时间过滤
        var str = start;
        var result = "";
        var obj = {};
        //将字符串转换成时间格式
        var timePublish = new Date(str);
        var timeNow = new Date(current);
        var minute = 1000 * 60;
        var hour = minute * 60;
        var day = hour * 24;
        var month = day * 30;
        var diffValue = timeNow - timePublish;
        var diffMonth = diffValue / month;
        var diffWeek = diffValue / (7 * day);
        var diffDay = diffValue / day;
        var diffHour = diffValue / hour;
        var diffMinute = diffValue / minute;

        if (diffValue < 0) {
          alert("错误时间");
        } else if (diffDay > 2) {
          result = timePublish.getFullYear() + "-";
          result += timePublish.getMonth() + "-";
          result += timePublish.getDate();
          // alert(result);
          obj = {
            time: result,
            show: "false",
          };
        } else if (diffDay > 1) {
          result = parseInt(diffDay) + "天前";
          obj = {
            time: result,
            show: "false",
          };
        } else if (diffHour > 3 || diffHour == 3) {
          // console.log("小时：", diffHour)
          result = parseInt(diffHour) + "小时前";
          obj = {
            time: result,
            show: "false",
          };
        } else if (diffHour > 1) {
          // console.log("小时：", diffHour)
          result = parseInt(diffHour) + "小时前";
          obj = {
            time: result,
            show: "true",
          };
        } else if (diffMinute > 1) {
          result = parseInt(diffMinute) + "分钟前";
          obj = {
            time: result,
            show: "true",
          };
        } else {
          result = "刚刚";
          obj = {
            time: result,
            show: "true",
          };
        }
        // console.log(obj)
        return obj;
      },
      // blurinpt(){
      //   this.search_inpt_bg_is = false
      //   if (this.search_ss.length != "") {
      //     this.search_inpt_bg_is = true
      //   }
      // },
      // focusinpt(){
      //   this.search_inpt_bg_is = true
      // },
      changeInput() {
        //监听input 值
        if (this.search_ss.length == "") {
          this.search_inpt_bg_is = false;
        } else {
          this.search_inpt_bg_is = true;
        }
        // console.log(this.search_ss)
      },
      open() {
        this.hidshow = false;
      },
      lose() {
        this.hidshow = true;
      },
      back() {
        var _this = this;
        _this.clickNum++;
        if (_this.clickNum > 1) {
          plus.runtime.quit();
        } else if (_this.clickNum == 1) {
          _this.mui.toast("再按一次退出应用");
        }
        setTimeout(function () {
          _this.clickNum = 0;
        }, 1000);
        return false;
      },
      xunchapaicha() {
        try {
          plus.nativeUI.showWaiting("正在加载...");
        } catch (e) {
          console.log("plus问题");
        }
        this.axios
          .get(
            `${this.$global_msg.Url.host}/Xx/selectStatusAndLev?userId=${this.userId}`
          )
          .then((res) => {
            try {
              plus.nativeUI.closeWaiting();
            } catch (e) {
              console.log("plus问题");
            }
            console.log(res);
            if (res.data.code == 0) {
              // let data = { "id": id, "type": type }
              // sessionStorage.setItem("scan_canshu_data", JSON.stringify(data))
              // localStorage.setItem("patrolTroubleshootId",res.data.rows.patrolTroubleshootId)
            } else {
              this.$toast(res.data.msg);
            }
          });
      },
      checkRwjb() {
        var _this = this;
        var params = {
          userId: _this.userId,
        };
        _this.axios
          .get(_this.$global_msg.Url.host + "/taskAssign/showIsCheck", {
            params: params,
          })
          .then(function (data) {
            try {
              plus.nativeUI.closeWaiting();
            } catch (e) {
              console.log(e.message);
            }
            console.log("selectNineStoreById:", data);
            if (data && data.data) {
              if (data.data.code == 200) {
                _this.red_is_rwjb = data.data.rows == 1 ? true : false;
              } else {
                _this.$toast(data.data.msg);
              }
            } else {
              _this.$toast("查询失败");
            }
          });
      },
      down_apk() {
        var _this = this;
        var Terminal = {
          // 辨别移动终端类型
          platform: (function () {
            var u = navigator.userAgent,
              app = navigator.appVersion;
            return {
              // android终端或者uc浏览器
              android: u.indexOf("Android") > -1 || u.indexOf("Linux") > -1,
              // 是否为iPhone或者QQHD浏览器
              iPhone: u.indexOf("iPhone") > -1,
              // 是否iPad
              iPad: u.indexOf("iPad") > -1,
            };
          })(),
          // 辨别移动终端的语言：zh-cn、en-us、ko-kr、ja-jp...
          language: (
            navigator.browserLanguage || navigator.language
          ).toLowerCase(),
        };
        // 根据不同的终端，跳转到不同的地址
        var theUrl = "";
        if (Terminal.platform.android) {
          // alert("安卓")
          theUrl = _this.showeditionObj.xzgxUrl;
          if (is_mobileWX() || is_mobileQQForAndroid()) {
          } else {
            location.href = theUrl;
          }
        } else if (Terminal.platform.iPhone) {
          theUrl = "https://itunes.apple.com/us/app/998dian-wan-cheng/id?mt=8";
          location.href = theUrl;
        }

        function is_mobileQQForAndroid() {
          var ua = navigator.userAgent.toLowerCase();
          if (ua.match(/\sQQ/i) == "qq" && /iphone/i.test(ua) == false) {
            return true;
          } else {
            return false;
          }
        }

        function is_mobileQQForIPhone() {
          var ua = navigator.userAgent.toLowerCase();
          if (ua.match(/\sQQ/i) == "qq" && /iphone/i.test(ua) == true) {
            return true;
          } else {
            return false;
          }
        }

        function is_mobileWX() {
          var ua = navigator.userAgent.toLowerCase();
          if (ua.match(/MicroMessenger/i) == "micromessenger") {
            return true;
          } else {
            return false;
          }
        }
      },
      UPdatas() {
        this.down_apk();
      },
      showed(index, id) {
        console.log(index, id);
        sessionStorage.setItem("showed", 1)
        if (id === 0) {
          //监督检查计划
          // 2865
          var name = localStorage.getItem("super");
          sessionStorage.setItem("jdjc_tongji_title", name);
          if (this.rank == 1) {
            this.$router.push("/tongji_1");
          } else if (this.rank == 2) {
            this.$router.push("/tongji_2");
          } else if (this.rank == 3) {
            this.$router.push("/tongji_3");
          }
        } else if (id === 1) {
          //任务交办
          localStorage.removeItem("rwjbDwType");
          this.$router.push("/rwjb_list");
        } else if (id === 2) {
          //宣传部署
          sessionStorage.setItem("where", 0);
          this.$router.push("/xcbs_list");
        } else if (id === 3) {
          //巡查排查
          this.$router.push("/community_list");
        } else if (id === 5) {
          //辖企档案
          this.$router.push("/xqda");
        } else if (id === 4) {
          //隐患整治
          this.axios
            .get(
              `${this.$global_msg.Url.host}/taskAssign/isPostOrGet?userId=${this.userId}`
            )
            .then((res) => {
              console.log(res);
              if (res.data.rows == 0) {
                this.$router.push("/yhzz_btn");
              } else if (res.data.rows == 1) {
                this.$router.push("/yhzz_btn1");
              } else if (res.data.rows == 2 || res.data.rows == 3) {
                this.$router.push("/yhzz_btn2");
              }
            });
        } else if (id === 6) {
          //统计查询
        } else if (id === 7) {
          //数据地图
          this.$router.push("/data_map");
        } else if (id === 8) {
          //点位巡查
          this.$router.push("/dwxc_1_calendar");
        }
      },
      ismobile(test) {
        var u = navigator.userAgent,
          app = navigator.appVersion;
        if (
          /AppleWebKit.*Mobile/i.test(navigator.userAgent) ||
          /MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(
            navigator.userAgent
          )
        ) {
          if (window.location.href.indexOf("?mobile") < 0) {
            try {
              if (/iPhone|mac|iPod|iPad/i.test(navigator.userAgent)) {
                // return "0";
                this.phone_type = 0;
                // alert("iphone")
              } else {
                // return "1";
                this.phone_type = 1;
                // alert("Android")
              }
            } catch (e) { }
          }
        } else if (u.indexOf("iPad") > -1) {
          // return "0";
          this.phone_type = 0;
          // alert("iphone")
        } else {
          // return "1";
          this.phone_type = 1;
          // alert("Android")
        }
      },
      //更新方法
      UpdateSystem() {
        if (this.sort == 0) {
          this.plusReady_gengxin();
        } else if (this.sort == 1) {
          this.plusReady_gengxin();
        }
      },
      // 更新方法
      plusReady_gengxin() {
        this.runtime_fun();
      },
      runtime_fun() {
        var _this = this;
        setTimeout(() => {
          plus.runtime.getProperty(plus.runtime.appid, function (inf) {
            // 当前版本

            var wgtVersion = inf.version;
            _this.axios
              .get(
                "/yzsafe-login-app/showedition",
                {},
                {
                  headers: {
                    "Content-Type": "application/x-www-form-urlencoded",
                  },
                }
              )
              .then(function (data) {
                // 如果有新版本，则提示需要更新
                console.log("aaaa");
                console.log(data.data.rows.zdgxNumber);
                console.log(wgtVersion);
                console.log(data.data.rows.zdgxNumber > wgtVersion);
                _this.showeditionObj = data.data.rows;
                if (data.data.rows.xzgxNumber > wgtVersion) {
                  _this.fuck = true;
                } else if (data.data.rows.zdgxNumber > wgtVersion) {
                  console.log(11111);
                  _this.$toast("有新版本可用");
                  setTimeout(() => {
                    console.log(2222);
                    _this.downloadWgt(); // 下载wgt方法
                  }, 1000);
                } else {
                  if (_this.sort == 1) {
                    console.log(33333);
                    // _this.Toast({
                    //   message: "已是最新版本！！！",
                    //   className: "toast_font"
                    // });
                    console.log("已是最新版本！！！");
                  } else {
                    return;
                  }
                }
              })
              .catch(function (err) {
                // 请求失败处理
                _this.$toast("获取更新资源失败！！！");
              });
          });
        }, 500);
      },
      // 下载wgt方法
      downloadWgt() {
        // 更新文件 wgt 文件地址
        var that = this;
        var wgtUrl = that.showeditionObj.zdgxUrl;
        plus.nativeUI.showWaiting("正在更新...");
        plus.downloader
          .createDownload(
            wgtUrl,
            {
              filename: "_doc/update/",
            },
            function (d, status) {
              if (status == 200) {
                console.log("下载wgt成功：" + d.filename);
                that.installWgt(d.filename); // 安装wgt方法
              } else {
                console.log("下载wgt失败！");
                plus.nativeUI.alert("下载wgt失败！");
              }
              plus.nativeUI.closeWaiting();
            }
          )
          .start();
      },
      //安装方法
      installWgt(path) {
        plus.nativeUI.showWaiting("安装wgt文件...");
        plus.runtime.install(
          path,
          {},
          function () {
            plus.nativeUI.closeWaiting();
            console.log("安装wgt文件成功！");
            plus.nativeUI.alert("应用资源更新完成！", function () {
              plus.runtime.restart();
            });
          },
          function (e) {
            plus.nativeUI.closeWaiting();
            console.log("安装wgt文件失败[" + e.code + "]：" + e.message);
            plus.nativeUI.alert("安装wgt文件失败[" + e.code + "]：" + e.message);
          }
        );
      },
      indexrank() {
        this.axios
          .get(
            `${this.$global_msg.Url.host}/monitoringPlan/isRight?userId=${this.userId}`
          )
          .then((res) => {
            console.log("权限级别", res);
            if (res.data.rows.dwlev == 0) {
              //区级
              this.rank = 1;
              sessionStorage.setItem("index_rank", 1);
            } else if (res.data.rows.dwlev == 1) {
              //街道
              this.rank = 2;
              sessionStorage.setItem("index_rank", 2);
            } else if (res.data.rows.dwlev == 2) {
              //社区、科室
              if (res.data.rows.dwlxid == 1) {
                //科室
                this.rank = 3;
                sessionStorage.setItem("index_rank", 3);
              } else {
                //社区
              }
            }
          });
      },
      getlist() {
        // try {
        //   plus.nativeUI.showWaiting("正在加载...");
        // } catch (e) {
        //   console.log(e.message);
        // }
        this.axios
          .get(
            `${this.$global_msg.Url.host}/SearchScreen/selectIndexQueryName?userId=${this.userId}&queryName=${this.search_ss}&pageSize=${this.cunt}&pageRows=10`,
            {
              headers: {
                "Content-Type": "application/json",
              },
            }
          )
          .then((res) => {
            try {
              plus.nativeUI.closeWaiting();
            } catch (e) {
              console.log(e.message);
            }
            if (res.data.code == -1) {
              this.loading = false;
              this.$toast(res.data.msg);
              this.finished = true;
              return false;
            }
            console.log("新闻列表：", res);
            console.log("=================");
            if (res.data.total == 0) {
              this.loading = false;
              this.$toast("暂无数据");
              this.finished = true;
              return false;
            }
            if (this.refreshing) {
              this.list = [];
              this.cunt = 1;
              this.refreshing = false;
            }

            // this.list = res.data.rows
            for (var i of res.data.rows) {
              // this.list=res.data.rows.list
              this.list.push(i);
            }
            this.total = res.data.total;

            this.cunt += 1;
            // 加载状态结束
            this.loading = false;
            console.log(this.list.length);
            if (this.total < this.list.length || this.total == this.list.length) {
              this.finished = true;
              console.log("加载完毕");
            }
          })
          .catch((error) => {
            console.log(error.message);
            let err = error.message;
            if (err === "Network Error" || err.includes("timeout")) {
              that.$toast("网络超时，请刷新重试！");
              try {
                plus.nativeUI.closeWaiting();
              } catch (e) {
                console.log("plus问题");
              }
            } else {
              alert(error);
            }
          });
      },
      onLoad() {
        // 异步更新数据
        // this.yc = true
        // if(this.cunt>2){return false}

        this.getlist();
      },
      onRefresh() {
        console.log("下拉");
        // 清空列表数据
        this.finished = false;
        this.refreshing = true;
        // this.yc=false
        // 重新加载数据
        // 将 loading 设置为 true，表示处于加载状态
        this.loading = true;
        this.cunt = 1;
        try {
          plus.nativeUI.showWaiting("正在加载...");
        } catch (e) {
          console.log("plus问题");
        }

        this.onLoad();
      },
    },

    components: {
      Header,
      Tabbar,
    },
    beforeRouteEnter(to, from, next) {
      next((vm) => {
        vm.UpdateSystem(); //检查当前app版本是否需要更新
        vm.ismobile(1);
        $(".content").animate(
          { scrollTop: localStorage.getItem("index_scroll") },
          0
        );
        vm.userId = localStorage.getItem("userId"); //用户id
        vm.tel = localStorage.getItem("tel"); //用户id
        vm.cardWhether = localStorage.getItem("cardWhether"); //用户id
        vm.checkRwjb();
        vm.indexrank();
        if (localStorage.getItem("userid_ben")) {
          vm.userId = localStorage.getItem("userid_ben");
          localStorage.setItem("userId", vm.userId);
        } else {
          localStorage.setItem("userid_ben", vm.userId);
        }
        // vm.getlist()
        vm.img_path = vm.$global_msg.Url.host;
        // console.log("++++++++++++++++++++++++++++++++")
        // console.log(sessionStorage.getItem("showed")==1)
        if (sessionStorage.getItem("showed") == 1) {
          vm.search_ss = ""
          vm.search_inpt_bg_is = false
          vm.list = [];

          vm.onRefresh()
        }
      });
    },
    created() {
      // this.ismobile(1);
      //  this.path=this.$global_msg.Url.hosted
      //localStorage.setItem("userId",2789);
      //localStorage.setItem("userId",2866);//监督检查计划
      //localStorage.setItem("userId",2824);
      //localStorage.setItem("userId",55);
      //localStorage.setItem("userId",2884);
      //localStorage.setItem("userId",2835);
      //localStorage.setItem("userId",2869);
      //localStorage.setItem("userId",2879);//街道
      //localStorage.setItem("userId",2881);
      //localStorage.setItem("userId",2881);
      //localStorage.setItem("userId",2867);//何朝东
      // localStorage.setItem("userId",2799);//街道权限
      //localStorage.setItem("userId",2871);//姚云
    },
  };
</script>

<style scoped>
  .van-tabbar {
    padding: 0.4rem 0;
  }

  #yy {
    height: 1.6667rem;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    border-top: 1px solid #cccccc;
  }

  #yy .van-tabbar--fixed {
    position: fixed;
    bottom: 0;
    left: 0;

    /* background: #0c1d37; */
  }

  .van-tabbar--fixed {
    border-top: 1px solid #cccccc;
    border: none;
    padding-top: 0.8rem;
  }

  .van-tabbar-item {
    font-size: 0.44rem;
    line-height: 0.6rem;
  }

  .van-tabbar-item__icon img {
    display: block;
    height: 0.5333rem;
  }

  [class*="van-hairline"]::after {
    border: none;
  }

  .fb {
    font-size: 0.481481rem;
    text-align: center;
    margin-top: 0.37037rem;
  }

  .savegg {
    font-size: 0.407407rem;
    text-align: center;
    margin-top: 0.185185rem;
  }

  .makesure {
    color: #007aff;
    font-size: 0.444444rem;
    width: 100%;
    text-align: center;
    margin-top: 0.37037rem;
  }

  .line {
    border-top: 1px solid#E5E5E5;
    margin-top: 0.740741rem;
  }

  /* .van-grid {
    position: fixed;
    bottom: 0;
    margin-bottom: 1.9rem;
  } */

  /* .van-grid-item:nth-child(3) img {
    display: none;
  } */

  /* .van-grid-item:nth-child(4) img {
    display: none;
  } */

  /*.van-grid-item:nth-child(3) .redx {
    display: none;
  }*/

  .van-grid-item:nth-child(4) .redx {
    display: none;
  }

  .van-grid-item__content {
    background: none;
  }

  .LGgin {
    margin: 0 auto;
    width: 2rem;
    height: 2rem;
    margin-top: 1.1111rem;
  }

  .save {
    text-align: center;
    font-size: 0.444444rem;
    color: #ffffff;
    margin-top: 0.185185rem;
  }

  .content_up {
    position: fixed;
    bottom: 0;
    margin-bottom: 2rem;
  }

  .box_box2 {
    display: flex;
    flex-wrap: wrap;
    margin-left: 0.6rem;
  }

  .box_box {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-left: 0.6rem;
  }

  .box_big {
    width: 25%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-sizing: border-box;
  }

  .content {
    width: 100%;
    height: 100vh;
    position: fixed;
    overflow-y: auto;
    z-index: 1;
  }

  .van-grid-item__content {
    background-color: none;
  }

  .icon {
    width: 1.8rem;
    height: 1.8rem;
  }

  .tit {
    color: #ffffff;
    font-size: 0.36rem;
    margin-top: -0.37037rem;
    margin-left: 0.222222rem;
  }

  .tit.active {
    margin-left: -0.2rem;
  }

  .title {
    font-size: 0.9333rem;
    color: #ffffff;
  }

  .platform {
    color: #ffffff;
    font-size: 0.5rem;
    margin-top: -1.6rem;
  }

  .service {
    margin: 0.37037037037037035rem 0 0 0.37037037037037035rem;
    font-size: 0.42592592592592593rem;
    color: #000;
    margin-bottom: 0.8rem;
  }

  .hours {
    width: 1rem;
    height: 1rem;
    /* filter: grayscale(100%); */
  }

  .grayscale {
    filter: grayscale(100%);
  }

  .van-grid-item__content {
    background: none;
    /* padding: 0; */
  }

  .box {
    margin-top: 0.8rem;
    overflow-x: auto;
    display: inline-flex;
    align-items: center;
  }

  .box>div {
    width: 2.3519rem;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.0741rem;
  }

  .words {
    font-size: 0.36rem;
    line-height: 0.3888888888888889rem;
    height: 0.3888888888888889rem;
    color: #ffffff;
    margin-top: 0.1852rem;
  }

  .money_photo {
    height: 0.5867rem;
    width: 0.4933rem;
  }

  .Repair_photo {
    width: 0.6rem;
    height: 0.6267rem;
  }

  .van-tabbar--fixed {
    border-top: 1px solid black;
  }

  .box {
    margin-top: 0.2778rem;
  }

  .wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
  }

  .block {
    width: 120px;
    height: 120px;
    background-color: #fff;
  }

  .content_box {
    background: rgba(0, 0, 0, 0.3);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 10000000000000;
  }

  .content_box_son {
    width: 76%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 0.37037037037037035rem;
    /* padding: 0.46296296296296297rem 0.6481481481481481rem; */
    z-index: 100;
  }

  .intro {
    text-indent: 0.7777777777777778rem;
    line-height: 0.5185185185185185rem;
    font-size: 0.388889rem;
  }

  .explanation {
    font-size: 0.48148148148148145rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 0.37037037037037035rem;
  }

  .select {
    display: flex;
    font-size: 0.388889rem;
    color: #007aff;
    justify-content: space-around;
    margin-top: 0.32rem;
  }

  .btn {
    width: 92.5%;
    height: 0.9259259259259259rem;
    border-radius: 0.09259259259259259rem;
    background: #2b6cfe;
    color: white;
    text-align: center;
    line-height: 0.9259259259259259rem;
    margin: inherit;
    font-size: 0.425rem;
    font-size: 0.32rem;
    border-radius: 1.277778rem;
  }

  .tipstitle {
    font-size: 0.48148148148148145rem;
    font-weight: 600;
    text-align: left;
    margin-bottom: 0.37037037037037035rem;
    border-bottom-color: #efeff0;
    border-bottom-style: solid;
  }

  .redx {
    width: 0.2704rem;
    height: 0.2704rem;
    background: #ff0000;
    border-radius: 50%;
    position: absolute;
    /* top: 0.5407rem; */
    top: 0.1rem;
    right: 0.7407rem;
    z-index: 100;
  }

  .top {
    width: 100%;
    height: 6.2267rem;
  }

  .content_box {
    background: rgba(0, 0, 0, 0.5);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 90;
    display: flex;
  }

  .content_box_song {
    width: 90%;
    /* height: 4.8267rem; */
    margin: auto;
    z-index: 100000000;
    align-items: center;
    justify-content: center;
    /* margin-bottom:100%; */
    background: white;
    border-radius: 0.37037rem;
    overflow: hidden;
    padding-bottom: 0.37037rem;
  }

  /* 头部样式 */
  .header_top {
    padding: 0 0.3148rem;
    padding-top: 0.9259rem;
    background-image: url("../assets/images/img/banner.png");
    /* height: 5.8704rem; */
    background-size: 100% 100%;
    box-sizing: border-box;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding-bottom: 0.1852rem;
    z-index: 100;
  }

  .header_top_search {
    display: flex;
    align-items: center;
  }

  .search {
    background: #fff;
    border-radius: 0.9259rem;
    flex: 1;
    height: 0.9259rem;
    position: relative;
    display: flex;
    align-items: center;
  }

  .search_inpt {
    height: 0.9259rem;
    padding: 0 0.3704rem;
    border-radius: 0.9259rem;
    width: 100%;
    box-sizing: border-box;
    font-size: 0.3889rem;
    z-index: 100;
    position: absolute;
    background: transparent;
    padding-right: 0.7407rem;
  }

  .search_inpt_bg {
    background: #fff;
  }

  .img_xj {
    width: 0.5926rem;
    height: 0.463rem;
    margin-left: 0.3148rem;
  }

  .search_bg {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
    height: 100%;
    font-size: 0.3889rem;
    color: #8c8c8c;
    z-index: 1;
    padding: 0 0.3704rem;
    box-sizing: border-box;
  }

  .img_ss {
    height: 0.3611rem;
    width: 0.3426rem;
  }

  .img_xx {
    height: 0.3611rem;
    width: 0.3426rem;
    position: absolute;
    right: 0.3704rem;
    z-index: 101;
  }

  .btn_ss {
    margin-left: 0.3148rem;
    color: #fff;
    font-size: 0.3889rem;
  }

  /* 头部完 */
  .hr {
    height: 0.1852rem;
    background: #f1f1f1;
    width: 100%;
  }

  /* 下面的列表 */
  .main-index {
    padding-top: 5.8704rem;
    padding-bottom: 1.6667rem;
  }

  .main_item {
    height: 2.4074rem;
    border-bottom: 1Px solid #ddd;
    display: flex;
    padding: 0.2778rem;
    justify-content: space-between;
  }

  .img_item {
    /* height: 100%; */
    height: 2.4074rem;
    width: 3.0185rem;
  }

  .item_left {
    height: 100%;
    margin-right: 0.1852rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0.0926rem 0;
    box-sizing: border-box;
    flex: 1;
  }

  .item_left_top {
    font-size: 0.425925rem;
    line-height: 0.5556rem;
    letter-spacing: 0.037rem;
    /* display: flex;
    flex-wrap: wrap;
    font-size: 0.3889rem; */

  }
  .item_left_top_item{
    display: flex;
    padding-left: 0.6667rem;
    position: relative;
  }

  .item_left_bottom {
    display: flex;
    padding-left: 0.6667rem;
    font-size: 0.2778rem;
    color: #7F8699;
  }

  .img_news {
    width: 0.5556rem;
    height: 0.2778rem;
    display: inline-block;
  }

  .van-swipe-item {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .miaoshu {
    width: 100%;
    padding-left: 0.6667rem;
    font-size: 0.3333rem;
    color: #7F8699;
    box-sizing: border-box;
  }

  .mar-top {
    padding-top: 2.037rem;
  }

  .mar-bot {
    padding-bottom: 5.5rem;
  }

  .img_list {
    width: 0.4815rem !important;
    height: 0.4815rem;
    margin-right: 0.1852rem;
    position: absolute;
    left:0;
  }
</style>